// 取到需要权限判断的路由表
import Vue from 'vue' /**权限指令**/
const has = Vue.directive('has', {
	bind: function(el, binding, vnode) {
		// 获取按钮权限 
		//let btnPermissions = vnode.context.$route.meta.btnPermissions.split(",");
		let btnPermissions = binding.value.toString();
		if(!Vue.prototype.$_has(btnPermissions)) {
			//console.log("el=",el);
			el.style.display='none';//隐藏按钮
		}
	}
}); // 权限检查方法
Vue.prototype.$_has = function(value) {
	let isExist = false;
	let btnPermissionsStr = sessionStorage.getItem("level");
		//console.log("用户按钮权限=",btnPermissionsStr);
		//console.log("按钮所需权限=",value);
	if(btnPermissionsStr == undefined || btnPermissionsStr == null) {
		return false;
	}
	if(value.indexOf(btnPermissionsStr) > -1) {
		isExist = true;
	}
	return isExist;
};
export {has}